package com.ykdl.member.kid.gears;

import com.lidroid.xutils.BitmapUtils;
import com.lidroid.xutils.bitmap.PauseOnScrollListener;
import com.ykdl.member.kid.R;
import com.ykdl.member.kid.image.ImageLoader;
import com.ykdl.member.kid.widget.dialog.DialogImpl;
import com.ykdl.member.views.PullToRefreshView;
import com.ykdl.member.views.PullToRefreshView.OnFooterRefreshListener;

import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

public abstract class AbsFragmentActivity extends BaseFragmentActivity implements OnFooterRefreshListener, OnItemClickListener, OnClickListener{
	
	public PullToRefreshView mPullToRefreshView;
	public ImageView iv_back_up;
	public GridView mGridView;
	public int cursor = 0;
	public int count = 50;
	public int total_count = 0;
	public int gridview_item_height;
	public int gridview_item_width;
	public boolean isFootRefresh = false;
	public TextView tv_title;
	public BitmapUtils  bitmapUtil = null;
	private DialogImpl dialog;
	private ProgressDialog progress;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getRequestData();
		setContentView(R.layout.doctor_talk_child_list_activity);
		bitmapUtil = new BitmapUtils(this.mContext);
		initView();
	}

	
	/**
	 * 初始化视图
	 */
	private void initView() {
		tv_title = (TextView) this.findViewById(R.id.tv_title);
		iv_back_up = (ImageView) this.findViewById(R.id.iv_back_up);
		iv_back_up.setOnClickListener(this);
		setTitle();
		mPullToRefreshView = (PullToRefreshView) this.findViewById(R.id.pullToResreshView);
		mPullToRefreshView.setOnFooterRefreshListener(this);
		mPullToRefreshView.setEnablePullLoadMoreDataStatus(true);
		mPullToRefreshView.setOnHeaderRefreshListener(null);
		mPullToRefreshView.setEnablePullTorefresh(false);
	
		mGridView = (GridView) findViewById(R.id.gv_doctor_talk_view);
		
		matchGridView();
		
		mGridView.setOnItemClickListener(this);
		mGridView.setOnScrollListener(new PauseOnScrollListener(bitmapUtil, false, true));
		
	}
	
	protected void removeFootRefreshView(){
		if(isFootRefresh){
			mPullToRefreshView.onFooterRefreshComplete();
		}
	}
	@Override
	public void onFooterRefresh(PullToRefreshView view) {
			isFootRefresh = true;
			getRequestData();
	}
	
	
	protected abstract void getRequestData();
	protected abstract void setTitle();
	protected abstract void matchGridView();
	protected abstract void showdata();
	
	
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.iv_back_up://标题栏左侧回退键
			this.finish();
			break;
		default:
			break;
		}
	}
}
